package cn.com.inossem.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import cn.com.inossem.base.RequestActivity;
import cn.com.inossem.utils.ActivityStackControlUtil;

import com.foxykeep.datadroid.requestmanager.Request;

/**
 * 
 * 添加好友
 * 
 * <p>
 * detailed comment
 * 
 * @author szc 2015-8-24
 * @see
 * @since 1.0
 */
public class AddFriendsActivity extends RequestActivity {

	EditText edittext;
	TextView addtext;
	ImageView back;

	// private StatusEnum statusEnum;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.main_tab_layout);
		initView();

	}

	@Override
	public void onDestroy() {
		ActivityStackControlUtil.remove(this);
		super.onDestroy();
	}

	private void initView() {
		back = (ImageView) this.findViewById(R.id.back);
		back.setOnClickListener(this);
		edittext = (EditText) this.findViewById(R.id.edittext);
		//edittext.setInputType(InputType.TYPE_CLASS_NUMBER);
		addtext = (TextView) this.findViewById(R.id.addtext);
		addtext.setOnClickListener(this);
	}

	@Override
	public Request getInitialRequest() {
		return null;

	}

	@Override
	public void onRequestSucess(Request request, Bundle bundle) {

	}

	@Override
	public void onRequestError(int exceptionType) {

	}

	public int getContentViewId() {
		return R.layout.addfriend_layout;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.back:
			finish();
			break;
		case R.id.addtext:
			if (!edittext.getText().toString().equals("")) {
				Intent intent = new Intent(this, FriendsDetailsActivity.class);
				intent.putExtra("phone", edittext.getText().toString());
				startActivityForResult(intent, 0);
			} else {
				Toast.makeText(this, "手机号不能为空！", Toast.LENGTH_LONG).show();
			}
			break;
		default:
			break;
		}
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		switch (resultCode) { // resultCode为回传的标记，我在B中回传的是RESULT_OK
		case 1:
			finish();
		default:
			break;
		}
	}
}
